<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Controller\redirect;
use think\Session;

class Article extends Controller
{
    public $one_class;//一级分类
    public $boy_class;//男生
    public $giry_class;//女生
    public $publish_class;//出版
    
    /**
     * 魔术方法   自执行
     *
     * @return \think\Response
     */
    public function __construct()
    {
        $one_class = Db::name('article_class')->where('parent_id',0)->select();
        $boy_class = Db::name('article_class')->where('parent_id',1)->select();
        $giry_class = Db::name('article_class')->where('parent_id',2)->select(); 
        $publish_class = Db::name('article_class')->where('parent_id',3)->select(); 
         
        $this->one_class = $one_class;
        $this->boy_class = $boy_class;
        $this->giry_class = $giry_class;   
        $this->publish_class = $publish_class;             
    }

    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $one_class = $this->one_class;
        $boy_class = $this->boy_class;
        $giry_class = $this->giry_class;
        $publish_class = $this->publish_class;
        $article = Db::name('article')->select();        
        return view('index',[
            'article' => $article,
            'one_class' => $one_class,
            'boy_class' => $boy_class,
            'giry_class' => $giry_class,
            'publish_class' => $publish_class            
        ]);
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
